package com.wanxi.controller.front;

import com.wanxi.domain.front.TypeModel;
import com.wanxi.domain.product.ProductModel;
import com.wanxi.domain.user.UserModel;
import com.wanxi.service.front.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("front")
@RestController
@CrossOrigin(allowCredentials = "true", origins = "http://localhost:63342", allowedHeaders = "*")//允许跨域请求
public class TypeController {
    @Autowired
    private TypeService typeService;

    @GetMapping("type")
    public List<TypeModel> findAll(Integer page,Integer limit){
        List<TypeModel> resultModel =typeService.findAll(page,limit);
        return resultModel;
    }
    /*根据id删除产品*/
    @PostMapping("delete")
    public int deleteById(@RequestBody TypeModel typeModel){

        int resultModel =  typeService.deleteByid(typeModel.getId());
        return resultModel;

    }
    /*新增产品*/
    @PostMapping("insert")
    public int insertProduct(@RequestBody TypeModel typeModel){

        int resultModel = typeService.insert(typeModel);

        return resultModel;

    }
}
